<template>
  <BasicModal @register="register" :btnKey="btnKey" :title="title" @ok="handleSubmit" width="60%">
    <div v-if="btnKey == 'btnBatchAdd'" style="margin: 20px 20px 0; text-align: center">
      <a-textarea v-model:value="value" :auto-size="{ minRows: 7, maxRows: 7 }" />
      <p style="color: red; text-align: center; margin-top: 10px">
        提示：请复制EXCEL文件至输入框中。可同时复制图纸信息</p
      >
    </div>
    <div v-else style="margin: 20px 20px 0; text-align: center">
      <a-textarea v-model:value="value" :auto-size="{ minRows: 7, maxRows: 7 }" />
      <p style="color: red; text-align: center; margin-top: 10px">
        提示：请复制EXCEL文件至输入框中。客户图号+图号+名称+单价。</p
      >
    </div>
  </BasicModal>
</template>
<script lang="ts">
  export default defineComponent({
    name: 'WorkCalendarModal',
    // components: { ADatePicker: DatePicker },
  });
</script>
<script setup lang="ts">
  import { defineComponent, ref } from 'vue';
  import { BasicModal, useModalInner } from '/@/components/Modal';
  import { bachEditPrice, copyExcel } from '/@/api/order/order';
  import { useMessage } from '/@/hooks/web/useMessage';
  const emit = defineEmits(['success', 'register']);
  const { showMessage } = useMessage();
  let title = ref<string>('');
  let btnKey = ref<string>('');
  let value = ref<string>('');
  const record = ref<any>({});
  const [register, { closeModal, setModalProps }] = useModalInner((e) => {
    record.value = e;
    value.value = '';
    title.value = e.title;
    btnKey.value = e.btnKey;
    console.log(e);
  });

  async function handleSubmit() {
    if (btnKey.value == 'btnBatchAdd') {
      const params: any = {
        orderId: record.value['order.id'],
        batchData: value.value,
      };
      const res = await copyExcel(params);
      showMessage(res.message);
      setTimeout(closeModal);
      emit('success', '');
    } else {
      const params: any = {
        orderId: record.value['order.id'],
        batchData: value.value,
      };
      const res = await bachEditPrice(params);
      showMessage(res.message);
      setTimeout(closeModal);
      emit('success', '');
    }
    
  }
</script>
<style scoped>
  .ant-picker {
    width: 80%;
  }
</style>
